module.exports = function($scope, $state, $stateParams,$resource,FileUploader,toaster, $http, $q){ 
  $scope.objs = {};
  $scope.objs.nameid = '1';
    
    $resource('/api/as/ggc/facediscerndao/getFDareaDetailBycode', {}, {}).save({'create_by':$scope.info.bind_seller_login_code},function (res) {
      if (res.errcode !== 0) {
        // alert("数据获取失败");
        return;
      }
      res.data.nameid='2';
      $scope.objs = res.data;
    });

 // 上传图片
 var uploader1 = $scope.uploader1 = new FileUploader({
  url: 'https://txy.juyouhx.com/Api/Api/ObjectToOss?topdir=aa&selfdir=bb'
});

uploader1.filters.push({
  name: 'imageFilter',
  fn: function(item /*{File|FileLikeObject}*/, options) {
      var type = '|' + item.type.slice(item.type.lastIndexOf('/') + 1) + '|';
      return '|jpg|png|jpeg|bmp|gif|'.indexOf(type) !== -1;
  }
});    
uploader1.onSuccessItem = function(fileItem, response, status, headers) {
  $scope.objs.img = response.savename; 
};

$scope.save =function() {
  console.log($scope.info);
  $scope.objs.create_by = $scope.info.bind_seller_login_code;
  $resource('/api/as/ggc/facediscerndao/createFDarea', {}, {}).save($scope.objs,function (res) {
    if (res.errcode !== 0) {
      alert(res.errmsg);
      return;
    }else{
      toaster.success({ title: "提示", body: "创建成功!"});
      $state.go('app.apotlist',{});
      // $scope.goback();
    }
  });
};


$scope.update =function(code) {
  console.log($scope.info);
  $scope.objs.create_by = $scope.info.bind_seller_login_code;
  console.log($scope.objs);
  $resource('/api/as/ggc/facediscerndao/updateFDareaBycode', {}, {}).save($scope.objs,function (res) {
    if (res.errcode !== 0) {
      alert(res.errmsg);
      return;
    }else{
      toaster.success({ title: "提示", body: "更改成功!"});
      $state.go('app.spotlist',{});
      // $scope.goback();
    }
  });
};


};